package com.ygqh.baby.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ygqh.baby.ao.QueryInfo;
import com.ygqh.baby.ao.ResultSet;
import com.ygqh.baby.mapper.BiChannelDayMapper;
import com.ygqh.baby.po.BiChannelDay;
import com.ygqh.baby.po.BiChannelDayExample;
import com.ygqh.baby.service.BiChannelDayService;

@Service
public class BiChannelDayServiceImpl implements BiChannelDayService {

	@Autowired
	private BiChannelDayMapper biChannelDayMapper;

	@Override
	public List<BiChannelDay> find() {
		BiChannelDayExample example = new BiChannelDayExample();
		example.createCriteria();
		return biChannelDayMapper.selectByExample(example);
	}

	@Override
	public int findCount() {
		BiChannelDayExample example = new BiChannelDayExample();
		example.createCriteria();
		return biChannelDayMapper.countByExample(example);
	}

	@Override
	public BiChannelDay findById(Long id) {
		return biChannelDayMapper.selectByPrimaryKey(id);
	}

	@Override
	public int save(BiChannelDay biChannelDay) {
		return biChannelDayMapper.insertSelective(biChannelDay);
	}

	@Override
	public int update(BiChannelDay biChannelDay) {
		return biChannelDayMapper.updateByPrimaryKeySelective(biChannelDay);
	}

	@Override
	public ResultSet<BiChannelDay> search(QueryInfo queryInfo, Date startDate, Date endDate, String q) {
		List<BiChannelDay> list = biChannelDayMapper.selectSuper(queryInfo, startDate, endDate, q);
		int count = biChannelDayMapper.countSuper(startDate, endDate, q);
		ResultSet<BiChannelDay> resultSet = new ResultSet<BiChannelDay>(count, list);
		return resultSet;
	}

	@Override
	public int saveOrUpdate(BiChannelDay biChannelDay) {
		int r = 0;
		if (biChannelDay.getId() != null) {
			r = this.update(biChannelDay);
		} else {
			r = this.save(biChannelDay);
		}
		return r;
	}

	@Override
	public int addBiChannelDayBatch(List<BiChannelDay> biChannelDayList) {
		return biChannelDayMapper.addBiChannelDayBatch(biChannelDayList);
	}

}
